﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using Microsoft.SqlServer.Management.Smo;

namespace Orange.Mvc4App.Controllers {
    using Models;
    using Services;
    using Infrastructure;
    using System.Drawing;

    public class TestController : BaseController {
        //
        // GET: /Test/


        [OutputCache(CacheProfile = "Test")]
        public ActionResult Index() {
            return View();
        }

        [HandleError(ExceptionType = typeof(FileNotFoundException), View = "NotExists.cshtml")]
        public ActionResult Book1() {
            string path = @"d:\Reading\算法导论.pdf";
            return File(path, "application/pdf");
        }

        [HandleError(ExceptionType = typeof(FileNotFoundException), View = "NotExists")]
        public ActionResult Book2() {
            string path = @"d:\Reading\Pro ASP.NET MVC 3 Framework 3rd Edition.pdf";
            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) {
                byte[] buffer = new byte[fs.Length];
                string contentType = "application/pdf";
                fs.Read(buffer, 0, buffer.Length);
                return File(buffer, contentType);
            }
        }
    }
}